| API Documentation |  |

- MAIN PAGE
- NAMESPACES
- CLASSES

Public Member Functions | List of all members
nkScripts::ScriptManager Class Referencefinal

Manages the scripts available in the component. More...

Inheritance diagram for nkScripts::ScriptManager:

## Public Member Functions
Script * | createOrRetrieve (nkMemory::StringView name)
Script * | get (nkMemory::StringView name)
Script * | getByIndex (unsigned int id)
void | rename (nkMemory::StringView currentName, nkMemory::StringView newName)
void | erase (nkMemory::StringView name)

## Detailed Description

Manages the scripts available in the component.

The manager always owns the memory allocated through it. External code should never call delete on memory retrieved through it. Note that the Script class can be instantiated directly without relying on the manager. The manager is provided as a tool to uniformize the API with the other components, allowing to manipulate nkScripts in a similar way if desirable.

## Member Function Documentation

## ◆ createOrRetrieve()

Script* nkScripts::ScriptManager::createOrRetrieve | ( | nkMemory::StringView | name | ) |

Creates if unavailable, or retrieves if available, a script given its name.

Parameters

  name | The name of the script to create or retrieve.

Returns
  The script, possibly newly created.

Remarks
  The manager is responsible for the memory returned. Deallocation should occur through ScriptManager::erase().

## ◆ get()

Script* nkScripts::ScriptManager::get | ( | nkMemory::StringView | name | ) |

Gets an existing script.

Parameters

  name | The name of the script to retrieve.

Returns
  The script attached to given name if available, nullptr if unavailable.

## ◆ getByIndex()

Script* nkScripts::ScriptManager::getByIndex | ( | unsigned int | id | ) |

Gets a script according to an index.

Parameters

  id | The index to search for.

Returns
  The script linked to given index if available, nullptr if unavailable.

Remarks
  If manager memory is manipulated between different calls to this method, it is possible indices return different scripts between the calls.

## ◆ rename()

void nkScripts::ScriptManager::rename | ( | nkMemory::StringView | currentName,
|  | nkMemory::StringView | newName
| ) |  |

Renames a script within memory.

Parameters

  currentName | The current name to find back the script to alter.
  newName | The new name to assign to the script.

## ◆ erase()

void nkScripts::ScriptManager::erase | ( | nkMemory::StringView | name | ) |

Erases a script, and free its memory.

Parameters

  name | The name of the script to erase.

The documentation for this class was generated from the following file:

- Documentation/Headers/NilkinsScripts/Scripts/ScriptManager.h